
module.exports = function ($http,$q,httpservice) {
    var invitationService = {};

    // 查询
    invitationService.search = function (phone,email) {
        var  params ={"cellphone":phone,"email":email};
        var deferred = $q.defer();
        $http({
            method: 'POST',
            url: httpservice.invitationCheckUrl,
            data:params,
            headers : {'Content-Type':'application/json'}
        }).then(function successCallback(response) {
            deferred.resolve(response.data);
        }, function errorCallback(response) {
            deferred.reject(response);
        });
        return deferred.promise;
    };

    // 邀请好友
    invitationService.invitationFriend = function (phone,email,userId,userName) {
        var  params ={"cellphone":phone,"email":email,"biglawuserid":userId,"biglawUserName":userName};
        var deferred = $q.defer();
        $http({
            method: 'POST',
            url: httpservice.invitationFriendUrl,
            data:params,
            headers : {'Content-Type':'application/json'}
        }).then(function successCallback(response) {
            deferred.resolve(response.data);
        }, function errorCallback(response) {
            deferred.reject(response);
        });
        return deferred.promise;
    };

    return invitationService;
};
